﻿using CID.Domain.Development;
using CID.Domain.Infrastructure;
using FluentNHibernate.Mapping;

namespace CID.Domain.Persistence.Mappings.Infrastructure
{
    public class DefinitionMap : EntityMap<Definition>
    {
        public const string DiscriminatorColumn = "Type";

        public DefinitionMap()
        {
            HasMany<ParameterValue>(x => x.ParameterValues);
            DiscriminateSubClassesOnColumn(DiscriminatorColumn).Length(25);
        }
    }

    public class ActivationDeactivationDefinitionMap : SubclassMap<ActivationDeactivationDefinition>
    {
        public ActivationDeactivationDefinitionMap()
        {
            DiscriminatorValue("ActivationDeactivation");
            References<Component>(x => x.Component).Column("Component_id");
            References<ActivationTemplate>(x => x.ActivationTemplate).Nullable().Access.CamelCaseField();
            References<DeactivationTemplate>(x => x.DeactivationTemplate).Nullable().Access.CamelCaseField();
        }
    }

    public class DeploymentDefinitionMap : SubclassMap<DeploymentDefinition>
    {
        public DeploymentDefinitionMap()
        {
            DiscriminatorValue("Deployment");
            References<Version>(x => x.Version).Column("Version_id");
            References<DeploymentTemplate>(x => x.DeploymentTemplate).Nullable().Access.CamelCaseField();
        }
    }
}
